package cn.fl.project.service.impl;

import cmm.comm.facade.framework.api.ISysDictionaryApiService;
import cmm.comm.facade.framework.dto.SysDictionaryDTO;
import cmm.mid.core.framework.page.KeyValueVO;
import cmm.mid.core.framework.page.Pager;
import cmm.user.facade.system.api.ISysOrgApiService;
import cmm.user.facade.system.dto.SysOrgDTO;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.framework.constant.DictionaryConstant;
import cn.fl.preloan.enums.LogBusinessTypeEnum;
import cn.fl.project.condition.PrjPrdBscInfoQueryCondition;
import cn.fl.project.condition.PrjQuatPrpsAttrQueryCondition;
import cn.fl.project.condition.PrjQuatPrpsCfgMQueryCondition;
import cn.fl.project.constant.PrjBscInfoConstant;
import cn.fl.project.constant.PrjQuatPrpsAttrConstant;
import cn.fl.project.constant.PrjQuatPrpsConstant;
import cn.fl.project.dto.PrjQuatPrpsCfgMDTO;
import cn.fl.project.service.*;
import cn.fl.project.transform.PrjQuatPrpsCfgMVOTransform;
import cn.fl.project.vo.PrjBscInfoVO;
import cn.fl.project.vo.PrjPrdBscInfoVO;
import cn.fl.project.vo.PrjQuatPrpsAttrPageVO;
import cn.fl.project.vo.PrjQuatPrpsCfgMVO;
import com.alibaba.fastjson.JSON;
import com.lionbridge.log.ext.ExtSlf4jLogger;
import com.lionbridge.log.ext.ExtSlf4jLoggerBuilder;
import com.lionbridge.log.ext.LogTypeEnum;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Description: 项目报价方案配置主信息表 客户端服务层接口实现
 * @Description: 业务层方法名称前缀：新增：add* 删除：remove* 修改：modify* 查询对象：select* get* 批量：batch* 查询集合：search*
 */
@Slf4j
@Service
public class PrjQuatPrpsCfgMServiceImpl implements IPrjQuatPrpsCfgMService {
	private static ExtSlf4jLogger logger = ExtSlf4jLoggerBuilder.create()
			.setLogger(log).setBusinessType(LogBusinessTypeEnum.QUOTATION_SCHEME.getCode())
			.setSubBusinessType(LogBusinessTypeEnum.QUOTATION_SCHEME.getCode())
			.setLogType(LogTypeEnum.BUSINESS).build().setKeywords("PrjQuatPrpsCfgD");
	/**
	 * TODO 自定义 API 暴露服务
	 */
	@Autowired
	private IProjectApiService projectApiService;

	/**
	 * 本地数据字典服务
	 */
	@Autowired
	private ISysDictionaryApiService sysDictionaryApiService;
	
	/**
	 * 方案配置属性服务
	 */
	@Autowired
	private IPrjQuatPrpsAttrService prjQuatPrpsAttrService;
	/**
	 * 项目基础信息服务
	 */
	@Autowired
	private IPrjBscInfoService prjBscInfoService;
	
	/**
	 * 项目基础信息服务
	 */
	@Autowired
	private IPrjPrdBscInfoService prjPrdBscInfoService;
	
	/**
	 * 组织架构API暴露服务
	 */
	@Autowired
	private ISysOrgApiService sysOrgApiService;
	
	@Override
	public PrjQuatPrpsCfgMVO selectById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			logger.info("报价方案配置主信息，获取详情，参数id为空");
			return null;
		}
		PrjQuatPrpsCfgMDTO dto = this.projectApiService.selectPrjQuatPrpsCfgMById(id, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
		return PrjQuatPrpsCfgMVOTransform.toVO(dto);
	}

	@Override
	public Long add(PrjQuatPrpsCfgMVO entity) throws BaseException{
		if(null == entity){
			logger.info("报价方案配置主信息，新增数据，参数为空");
			return null;
		}
		return this.projectApiService.addPrjQuatPrpsCfgM(PrjQuatPrpsCfgMVOTransform.toDTO(entity));
	}

	@Override
	public boolean removeById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			logger.info("报价方案配置主信息，删除数据，参数id为空");
			return false;
		}
		//return this.prjQuatPrpsCfgMApiService.removeById(id);
		//TODO 业务逻辑
		return false;
	}
	
	/**
     * 删除
     * @param ids
     * @return
     */
    public boolean removeByIds(List<Long> ids)throws BaseException{
    	if(CollectionUtils.isEmpty(ids)){
			logger.info("报价方案配置主信息，批量删除数据，参数ids为空");
			return false;
		};
		return this.projectApiService.removePrjQuatPrpsCfgMByIds(ids);
    }

	@Override
	public boolean modify(PrjQuatPrpsCfgMVO entity) throws BaseException{
		if(null == entity){
			logger.info("报价方案配置主信息，修改数据，参数为空");
			return false;
		}
		return this.projectApiService.modifyPrjQuatPrpsCfgM(PrjQuatPrpsCfgMVOTransform.toDTO(entity), CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
	}

	@SuppressWarnings("unchecked")
	@Override
	public Pager searchListPage(Pager page) throws BaseException{
		if(null == page)page = new Pager();
		page = this.projectApiService.searchPrjQuatPrpsCfgMListPage(page, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
		List<PrjQuatPrpsCfgMDTO> dtoList = (List<PrjQuatPrpsCfgMDTO>) page.getResultList();
		List<PrjQuatPrpsCfgMVO> voList = PrjQuatPrpsCfgMVOTransform.toVOList(dtoList);
		if(CollectionUtils.isNotEmpty(voList)){
			for (PrjQuatPrpsCfgMVO prjQuatPrpsCfgMVO : voList) {
				PrjQuatPrpsAttrPageVO prjQuatPrpsAttrPageVO = this.prjQuatPrpsAttrService.selectPrjQuatPrpsAttrPageVOById(prjQuatPrpsCfgMVO.getId());
				prjQuatPrpsCfgMVO.setPrjQuatPrpsAttrPageVO(prjQuatPrpsAttrPageVO);
			}
		}
		page.setResultList(voList);
		return page;
	}
	
	/**
	 * 根据字典中代码组值获取组员集合
	 * @param grpCd 代码组值
	 * @return 集合
	 */
	private List<KeyValueVO> getKvList(String grpCd){
		List<KeyValueVO> kvList = new ArrayList<>();
		try {
			List<SysDictionaryDTO> sysDictionaryDTOList = this.sysDictionaryApiService.searchGroup(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), grpCd);
			if(CollectionUtils.isNotEmpty(sysDictionaryDTOList)){
				for (SysDictionaryDTO sysDictionaryDTO : sysDictionaryDTOList) {
					KeyValueVO keyValueVO = new KeyValueVO();
					keyValueVO.setKey(sysDictionaryDTO.getCode());
					keyValueVO.setValue(sysDictionaryDTO.getCodeNm());
					kvList.add(keyValueVO);
				}
			}
		} catch (BaseException e) {
			logger.error("获取字典项组,业务异常grpCd:{},msg:{}",grpCd,e.getMessage());
		} catch (Exception e) {
			logger.error("获取字典项组,系统异常grpCd：{},msg:{}",grpCd,e.getMessage());
		}
		return kvList;
	}

	@Override
	public List<KeyValueVO> searchPrpsTypCdList() throws BaseException {
		return this.getKvList(DictionaryConstant.CODE_PRJ_QUAT_PRPS_TYP_CD);
	}
	
	@Override
	public List<KeyValueVO> searchPrpsPrdTypCdList() throws BaseException {
		return this.getKvList(DictionaryConstant.CODE_PRJ_QUAT_PRPS_PRD_TYP_CD);
	}

	@Override
	public List<KeyValueVO> searchLsPdUntCdList() throws BaseException {
		return this.getKvList(DictionaryConstant.CODE_PRJ_QUAT_LS_PD_UNT_CD);
	}

	@Override
	public List<KeyValueVO> searchPayWayCdList() throws BaseException {
		return this.getKvList(DictionaryConstant.CODE_PRJ_QUAT_PAY_WAY_CD);
	}

	@Override
	public List<KeyValueVO> searchSplRebPolicyList() throws BaseException {
		return this.getKvList(DictionaryConstant.CODE_PRJ_QUAT_SPL_REB_POLICY);
	}

	@Override
	public List<KeyValueVO> searchDpstHdlWayCdList() throws BaseException {
		return this.getKvList(DictionaryConstant.CODE_PRJ_QUAT_DPST_HDL_WAY_CD);
	}

	@Override
	public List<KeyValueVO> searchExpHdlWayCdList() throws BaseException {
		return this.getKvList(DictionaryConstant.CODE_PRJ_QUAT_EXP_HDL_WAY_CD);
	}
	@Override
	public List<KeyValueVO> searchPolicyTypeCdList() throws BaseException {
		return this.getKvList(DictionaryConstant.CODE_POLICY);
	}

	@Override
	public List<KeyValueVO> searchOneCityOnePolicyTypeCdList(String orgCd) throws BaseException {
		List<KeyValueVO> kvList = new ArrayList<>();
		String codeGrpCd = DictionaryConstant.CODE_ONE_CITY_ONE_POLICY;
		if(StringUtils.isNotBlank(orgCd) && orgCd.length()>=4){
			int orgLen = orgCd.length();
			for(int i = 1;i<orgLen/4 + 1;i++){
				String useOrgCd = orgCd.substring(0,4*i);
				List<SysDictionaryDTO> sysDictionaryDTOList = this.sysDictionaryApiService.searchGroup(CurrentThreadContext.getFlServiceSysCd(),useOrgCd ,codeGrpCd);
				if(CollectionUtils.isNotEmpty(sysDictionaryDTOList)){
					for (SysDictionaryDTO sysDictionaryDTO : sysDictionaryDTOList) {
						KeyValueVO keyValueVO = new KeyValueVO();
						keyValueVO.setKey(sysDictionaryDTO.getCode());
						keyValueVO.setValue(sysDictionaryDTO.getCodeNm());
						kvList.add(keyValueVO);
					}
					break;
				}
			}
		}
		return kvList;
	}


	@Override
	public List<KeyValueVO> searchYesOrNoCdList() throws BaseException {
		return this.getKvList(DictionaryConstant.CODE_SYS_YES_NO_CD);
	}

	@Override
	public List<KeyValueVO> searchIsBpListList() throws BaseException {
		return this.getKvList(DictionaryConstant.CODE_IS_BP_LIST_CD);
	}

	@Override
	public List<KeyValueVO> searchCarClList() throws BaseException {
		return this.getKvList(DictionaryConstant.CODE_CAR_CL_CD);
	}
	
	/**
	 * 
	 */
	@Override
	public JSONArray searchFeeTypCdList() throws BaseException {
		JSONArray tree = new JSONArray();
		try {
			List<SysDictionaryDTO> sysDictionaryDTOList = this.sysDictionaryApiService.searchGroup(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), DictionaryConstant.CODE_PRJ_QUAT_FEE_TYP_CD);
			if(CollectionUtils.isNotEmpty(sysDictionaryDTOList)){
				for (SysDictionaryDTO sysDictionaryDTO : sysDictionaryDTOList) {
					if(BaseConstant.IS_YESNO_YES!=sysDictionaryDTO.getIsSysDef()){
						JSONObject obj = new JSONObject();
						obj.put("code", sysDictionaryDTO.getCode());
						obj.put("codeNm", sysDictionaryDTO.getCodeNm());
						obj.put("isSysDef", sysDictionaryDTO.getIsSysDef());
						if(BaseConstant.IS_YESNO_YES==sysDictionaryDTO.getIsSysDef()){
							obj.put("isSysDefNm", BaseConstant.IS_YESNO_YES_NM);
						}else if(BaseConstant.IS_YESNO_NO==sysDictionaryDTO.getIsSysDef()){
							obj.put("isSysDefNm", BaseConstant.IS_YESNO_NO_NE);
						}
						tree.add(obj);
					}
				}
			}
		} catch (BaseException e) {
			logger.error("获取字典项组,业务异常,msg:{}",e.getMessage());
		} catch (Exception e) {
			logger.error("获取字典项组,系统异常，msg:{}",e.getMessage());
		}
		return tree;
	}

	@Override
	public List<KeyValueVO> searchCalBaseCdList() throws BaseException {
		return this.getKvList(DictionaryConstant.CODE_PRJ_QUAT_CAL_BASE_CD);
	}

	@Override
	public List<KeyValueVO> searchCntWayCdList() throws BaseException {
		return this.getKvList(DictionaryConstant.CODE_PRJ_QUAT_CNT_WAY_CD);
	}
	@Override
	public List<KeyValueVO> searchBuOrgCdList() throws BaseException {
		List<SysOrgDTO> dtoList = this.sysOrgApiService.searchListByOrgTypCd(CurrentThreadContext.getFlServiceSysCd());
		List<KeyValueVO> kvList = new ArrayList<KeyValueVO>();
		if(CollectionUtils.isNotEmpty(dtoList)){
			for (SysOrgDTO dto : dtoList) {
				KeyValueVO kv = new KeyValueVO();
				kv.setKey(dto.getOrgCd());
				kv.setValue(dto.getOrgDispNm());
				kvList.add(kv);
			}
		}
		return kvList;
	}

	@Override
	public boolean modifyEnAblePrjQuatPrpsCfgM(PrjQuatPrpsCfgMVO entity) throws BaseException {
		if(null == entity || entity.getId()==null || entity.getIsValid()==null){
			logger.info("启用报价方案失败,缺少必要的参数条件(方案ID和启用标识)");
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		return this.projectApiService.modifyEnAblePrjQuatPrpsCfgM(PrjQuatPrpsCfgMVOTransform.toDTO(entity));
	}

	@Override
	public boolean modifyDisAblePrjQuatPrpsCfgM(PrjQuatPrpsCfgMVO entity) throws BaseException {
		if(null == entity || entity.getId()==null || entity.getIsValid()==null){
			logger.info("禁用报价方案失败,缺少必要的参数条件(方案ID和启用标识)");
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600,BaseExceptionConstant.BASE_EXCEPTION_CODE_600_NAME);
		}
		return this.projectApiService.modifyDisAblePrjQuatPrpsCfgM(PrjQuatPrpsCfgMVOTransform.toDTO(entity));
	}
	@Override
	public Pager  searchIsUsePrjQuatPrpsCfgMList(Pager page,Long prjId) throws BaseException {
		
		if(null ==prjId) return null;
		PrjBscInfoVO prj = this.prjBscInfoService.selectById(prjId);
		PrjPrdBscInfoQueryCondition prdQc  = new PrjPrdBscInfoQueryCondition();
		prdQc.setPrjId(prjId);
		List<PrjPrdBscInfoVO> prjPrdList = this.prjPrdBscInfoService.searchList(prdQc);
		 List<String> attrCdList = new ArrayList<String>(); //属性代码
		 List<String> attrValList = new ArrayList<String>(); // 属性值
		PrjQuatPrpsAttrQueryCondition qc = new PrjQuatPrpsAttrQueryCondition();
		List<SysDictionaryDTO> dictList = this.sysDictionaryApiService.searchGroup(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), DictionaryConstant.CODE_PRJ_QUAT_CFG_ATTR_CD);
		for (SysDictionaryDTO sysDictionaryDTO : dictList) {
			String col = sysDictionaryDTO.getCode();
			if(col.equals(PrjQuatPrpsAttrConstant.CODE_PRPS_ATTR_BIZ_TYP_CD)){
				if(StringUtils.isNotBlank(prj.getBizTypCd())){
					attrCdList.add(col);
					attrValList.add(prj.getBizTypCd());
				}
			}
			if(col.equals(PrjQuatPrpsAttrConstant.CODE_PRPS_ATTR_PRJ_TYP_CD)){
				if(StringUtils.isNotBlank(prj.getPrjTypCd())){
					attrCdList.add(col);
					attrValList.add(prj.getPrjTypCd());
				}
			}
			if(col.equals(PrjQuatPrpsAttrConstant.CODE_PRPS_ATTR_SPL_TYP_CD)){
				if(StringUtils.isNotBlank(prj.getAgntTypCd())){
					attrCdList.add(col);
					attrValList.add(prj.getAgntTypCd());
				}
			}
			if(col.equals(PrjQuatPrpsAttrConstant.CODE_PRPS_ATTR_BIZ_RES_CD)){
				if(StringUtils.isNotBlank(prj.getBizResCd())){
					attrCdList.add(col);
					attrValList.add(prj.getBizResCd());
				}
			}
			if(col.equals(PrjQuatPrpsAttrConstant.CODE_PRPS_ATTR_IS_GRP_ORDER)){
				if(null!=prj.getIsGrpBiz()){
					attrCdList.add(col);
					attrValList.add(prj.getIsGrpBiz().toString());
				}
			}
		/*	if(col.equals(PrjQuatPrpsAttrConstant.CODE_PRPS_ATTR_RGN_PR_CD)){
				if(null!=prj.getRgnPrCd()){
					attrCdList.add(col);
					attrValList.add(prj.getRgnPrCd());
				}
			}
			if(col.equals(PrjQuatPrpsAttrConstant.CODE_PRPS_ATTR_RGN_CY_CD)){
				if(null!=prj.getRgnCyCd()){
					attrCdList.add(col);
					attrValList.add(prj.getRgnCyCd());
				}
			}*/
			if(col.equals(PrjQuatPrpsAttrConstant.CODE_PRPS_ATTR_SPL_IDS)){
				if(CollectionUtils.isNotEmpty(prjPrdList)){
					attrCdList.add(col);
					for (PrjPrdBscInfoVO prjPrdBscInfoVO : prjPrdList) {
						if(null!=prjPrdBscInfoVO.getSplId()){
							attrValList.add(prjPrdBscInfoVO.getSplId().toString());
						}
					}
				}
				
			}
			if(col.equals(PrjQuatPrpsAttrConstant.CODE_PRPS_ATTR_BR_CD)){
				if(CollectionUtils.isNotEmpty(prjPrdList)){
					attrCdList.add(col);
					for (PrjPrdBscInfoVO prjPrdBscInfoVO : prjPrdList) {
						if(null!=prjPrdBscInfoVO.getBrCd()){
							attrValList.add(prjPrdBscInfoVO.getBrCd().toString());
						}
					}
				}
			}
			if(col.equals(PrjQuatPrpsAttrConstant.CODE_PRPS_ATTR_PRD_TYP_CD)){
				if(CollectionUtils.isNotEmpty(prjPrdList)){
					attrCdList.add(col);
					for (PrjPrdBscInfoVO prjPrdBscInfoVO : prjPrdList) {
						attrValList.add(prjPrdBscInfoVO.getPrdTypCd().toString());
					}
				}
			}
			if(col.equals(PrjQuatPrpsAttrConstant.CODE_PRPS_ATTR_PRD_MDL)){
				if(CollectionUtils.isNotEmpty(prjPrdList)){
					boolean flag = false;
					for (PrjPrdBscInfoVO prjPrdBscInfoVO : prjPrdList) {
						if(StringUtils.isNotBlank(prjPrdBscInfoVO.getPrdMdl())){
							flag = true;
							attrValList.add(prjPrdBscInfoVO.getPrdMdl().toString());
						}
					}
					if(flag){
						attrCdList.add(col);
					}
				}
			}
			
			if(col.equals(PrjQuatPrpsAttrConstant.CODE_PRPS_ATTR_ORGCD)){
				if(StringUtils.isNotBlank(prj.getCstMgrOrgCd())){
					attrCdList.add(col);
					attrValList.add(prj.getCstMgrOrgCd());
				}
			}
			
		}
		Pager pager = new Pager();
		//查询配置属性中可用的属性
		qc.setAttrCdList(attrCdList);
		qc.setAttrValList(attrValList);
		List<Long> idList = this.prjQuatPrpsAttrService.getIsUseQuatPrpsAttr(qc);
		if(CollectionUtils.isNotEmpty(idList)){
			//查询可用的属性的具体信息
			PrjQuatPrpsCfgMQueryCondition cfgqc = (PrjQuatPrpsCfgMQueryCondition)page.getCondition();
			cfgqc.setExpStDt(new Date());
			cfgqc.setIsValid(BaseConstant.IS_YESNO_YES);
			cfgqc.setIdList(idList);
			page.setCondition(cfgqc);
			pager = this.projectApiService.searchPrjQuatPrpsCfgMListPage(page, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
				List<PrjQuatPrpsCfgMDTO> dtoList = (List<PrjQuatPrpsCfgMDTO>) pager.getResultList();
				List<PrjQuatPrpsCfgMVO> voList = PrjQuatPrpsCfgMVOTransform.toVOList(dtoList);
			/*	if(CollectionUtils.isNotEmpty(voList)){
					pager.setResultList(voList);
				}*/
			pager.setResultList(voList);
			/**
			 * 机构限制
			 */
			if(BaseConstant.IS_YESNO_YES == prj.getIsInsBiz()){
				List<String> attrCdListIns = new ArrayList<String>(); //属性代码
				List<String> attrValListIns = new ArrayList<String>(); // 属性值
				attrCdListIns.add(PrjQuatPrpsAttrConstant.CODE_PRPS_ATTR_INS);
				attrValListIns.add(prj.getInsCode());
				qc.setAttrCdList(attrCdListIns);
				qc.setAttrValList(attrValListIns);
				logger.info("查询资管方案列表,请求参数qc：{}", JSON.toJSONString(qc));
				List<Long> idListIns = this.prjQuatPrpsAttrService.getIsUseQuatPrpsAttr(qc);
				logger.info("查询资管方案列表,返回结果result:{}", JSON.toJSONString(idListIns));
				List<PrjQuatPrpsCfgMVO> insList = new ArrayList<PrjQuatPrpsCfgMVO>();
				if(CollectionUtils.isNotEmpty(idListIns)){
					cfgqc.setIdList(idListIns);
					page.setCondition(cfgqc);
					logger.info("查询资管方案列表,请求参数page：{}", JSON.toJSONString(page));
					Pager pagerIns = this.projectApiService.searchPrjQuatPrpsCfgMListPage(page, CurrentThreadContext.getFlServiceSysCd(), CurrentThreadContext.getCurrentOrgCd());
					logger.info("查询资管方案列表,返回结果result:{}", JSON.toJSONString(pagerIns));
					List<PrjQuatPrpsCfgMDTO> dtoListIns = (List<PrjQuatPrpsCfgMDTO>) pagerIns.getResultList();
					List<PrjQuatPrpsCfgMVO> voListIns = PrjQuatPrpsCfgMVOTransform.toVOList(dtoListIns);
					if(CollectionUtils.isNotEmpty(voListIns)){
						for(PrjQuatPrpsCfgMVO prjQuatPrpsCfgMVOIns : voListIns){
							for(PrjQuatPrpsCfgMVO prjQuatPrpsCfgMVO : voList){
								if(prjQuatPrpsCfgMVOIns.getId().equals(prjQuatPrpsCfgMVO.getId())){
									insList.add(prjQuatPrpsCfgMVOIns);
								}
							}
						}
					}
				}
				pager.setResultList(insList);
				logger.info("查询资管列表,返回结果result", JSON.toJSONString(pager));
			}
				if(CollectionUtils.isNotEmpty(voList)){
					//乘用车根据新车和二手车查询
					if(prj.getBuOrgCd().equals(PrjBscInfoConstant.CODE_BU_ORG_CD_QCJR)){
						List<PrjQuatPrpsCfgMVO> cfgMVOList = new ArrayList<PrjQuatPrpsCfgMVO>();
					
						List<PrjQuatPrpsCfgMVO> secList = new ArrayList<PrjQuatPrpsCfgMVO>();
						List<PrjQuatPrpsCfgMVO> newList = new ArrayList<PrjQuatPrpsCfgMVO>();
						List<PrjQuatPrpsCfgMVO> ghSecList = new ArrayList<PrjQuatPrpsCfgMVO>();
						List<PrjQuatPrpsCfgMVO> ghNewList = new ArrayList<PrjQuatPrpsCfgMVO>();
						int isNew = prjPrdList.get(0).getIsNew();
						
						for(int i=0;i<voList.size();i++){
							String prpsNm = voList.get(i).getPrpsCfgNm();
							if(voList.get(i).getPayWayCd().equals(PrjQuatPrpsConstant.CODE_MULTI__STEP_INTER_GH)){
								if(prpsNm.contains("二")){
									ghSecList.add(voList.get(i));
								}else{
									ghNewList.add(voList.get(i));
								}
							}else{
								if(prpsNm.contains("二")){
									secList.add(voList.get(i));
								}else{
									newList.add(voList.get(i));
								}
							}
							
						}
						if(StringUtils.isNotBlank(prj.getBizTypCd())&&prj.getBizTypCd().equals(PrjBscInfoConstant.CODE_BIZ_TYP_CD_GSYH)){
							if(isNew==BaseConstant.IS_YESNO_NO){
								pager.setResultList(ghSecList);
							}
							if(isNew==BaseConstant.IS_YESNO_YES){
								pager.setResultList(ghNewList);
							}
						}else{
							if(isNew==BaseConstant.IS_YESNO_NO){
								pager.setResultList(secList);
							}
							if(isNew==BaseConstant.IS_YESNO_YES){
								pager.setResultList(newList);
							}
						}
						
					}/*else{
						pager.setResultList(voList);
					}*/
				}
		}/*else{
			//查询可用的属性的具体信息
			PrjQuatPrpsCfgMQueryCondition cfgqc = (PrjQuatPrpsCfgMQueryCondition)page.getCondition();
			cfgqc.setExpStDt(new Date());
			cfgqc.setIsValid(BaseConstant.IS_YESNO_YES);
			//cfgqc.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
			pager = this.projectApiService.searchPrjQuatPrpsCfgMListPage(page, CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd());
				List<PrjQuatPrpsCfgMDTO> dtoList = (List<PrjQuatPrpsCfgMDTO>) page.getResultList();
				List<PrjQuatPrpsCfgMVO> voList = PrjQuatPrpsCfgMVOTransform.toVOList(dtoList);
				if(CollectionUtils.isNotEmpty(voList)){
					pager.setResultList(voList);
				}
		}*/
		return pager;
	}


	@Override
	public Map<String, String> getDecimalDigitsByBuOrgCode(String sysCd, String orgCd) throws BaseException {
		if(StringUtils.isEmpty(sysCd)) sysCd = CurrentThreadContext.getCurrentSysCd();
		if(StringUtils.isEmpty(orgCd)) orgCd = CurrentThreadContext.getCurrentOrgCd();
		return this.projectApiService.getDecimalDigitsByBuOrgCode(sysCd, orgCd);
	}

	@Override
	public List<KeyValueVO> searchVehCheckCdList () throws BaseException {
		return this.getKvList(DictionaryConstant.VEH_CHECK_CD);
	}
}
